package com.homestay.controller;

import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import com.homestay.beans.UserInfoBean;
import com.homestay.service.IUserInfoService;
import com.homestay.service.IUserService;

@Controller
public class UserInfoController {
	@Autowired
	private IUserInfoService userInfoService;
	

	/**
	 * 查询用户个人信息
	 */
	@RequestMapping("/ShowMyInfo.action")
	
	public @ResponseBody UserInfoBean showUserInfo(@RequestParam String userId){
		
		UserInfoBean bean=userInfoService.showMyInfo(userId);
		return bean;
		
	}
	
	/**
	 * 修改用户个人信息
	 */
	@RequestMapping("/UpMyInfo.action")
	public @ResponseBody String upMyInfo(HttpServletRequest req){
		String userId=req.getParameter("userId");
		String nickName=req.getParameter("nickName");
		String realName=req.getParameter("realName");
		String cardId=req.getParameter("cardId");
		String sex=req.getParameter("sex");
		String age=req.getParameter("age");
		String email=req.getParameter("email");
		String mobile=req.getParameter("mobile");
		//进行信息修改，获取修改结果
		String result=userInfoService.upMyInfo(userId,nickName,realName,cardId,sex,age,email,mobile);
		return result;
	}
	
}
